home *** CD-ROM | disk | FTP | other *** search
- /* getstr.c - get a line of input from keyboard */
- /* this is a subroutine function */
-
- #include "stdio.h"
-
- int getstr(s,maxs) /* get a line of input */
- char s[] ; /* place the input here in string form */
- int maxs ; /* limit on characters allowed */
- { /* returns string length */
- int i , c ;
-
- i = 0 ;
- c = getchar() ; /* get first character */
- /* repeat til full, EOF or end-of-line */
- while( (i < maxs) && (c != '\n') && ( c != EOF) )
- { s[i] = c ; /* place char in string */
- i = i + 1 ; /* advance char count */
- c = getchar() ; /* and get another character */
- }
- s[i] = '\0' ;
- return( i ) ; /* return count of characters */
- }
-